home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / wfc007.000 / include / serport.hpp < prev    next >
C/C++ Source or Header  |  1996-04-08  |  2KB  |  81 lines

  1. #if ! defined( SERIAL_PORT_CLASS_HEADER )
  2.  
  3. /*
  4. ** Author: Samuel R. Blackburn
  5. ** CI$: 76300,326
  6. ** Internet: sammy@sed.csc.com
  7. **
  8. ** You can use it any way you like.
  9. */
  10.  
  11. #define SERIAL_PORT_CLASS_HEADER
  12.  
  13. class CSerialPort : public CObject
  14. {
  15.    private:
  16.  
  17.       void m_Initialize( DWORD input_buffer_size, DWORD output_buffer_size );
  18.  
  19.    protected:
  20.  
  21.       HANDLE m_FileHandle;
  22.  
  23.       DWORD m_ErrorCode;
  24.  
  25.       CDeviceControlBlock m_DeviceControlBlock;
  26.  
  27.       HANDLE m_ReceivedACharacterEvent;
  28.  
  29.       COverlapped m_ReadingOverlapped;
  30.  
  31.    public:
  32.  
  33.       CSerialPort();
  34.      ~CSerialPort();
  35.  
  36.       enum Parity
  37.       {
  38.          parityNone  = 0,
  39.          parityOdd   = 1,
  40.          parityEven  = 2,
  41.          parityMark  = 3,
  42.          paritySpace = 4
  43.       };
  44.  
  45.       /*
  46.       ** Methods
  47.       */
  48.  
  49.       BOOL OpenSynchronously();
  50.       BOOL OpenAsynchronously();
  51.  
  52.       BOOL ReadSynchronously( CByteArray& where_to_put_bytes );
  53.       BOOL ReadAsynchronously( const HANDLE event_to_set_when_data_comes_in );
  54.  
  55.       BOOL WriteSynchronously( const CByteArray& what_to_write );
  56.       BOOL WriteAsynchronously( const HANDLE event_to_set_when_data_is_written, const CByteArray& what_to_write );
  57.  
  58.       virtual BOOL Close( void );
  59.       virtual BOOL Open();
  60.  
  61.       virtual BOOL SetBaud( DWORD new_baud_rate );
  62.       virtual BOOL SetParity( Parity new_parity_setting );
  63.       BOOL SetStopBits( DWORD stop_bits );
  64.       BOOL SetDataBits( DWORD data_bits );
  65.  
  66.  
  67.       /*
  68.       ** Helpers
  69.       */
  70.  
  71.       inline  BOOL Read( CByteArray& where_to_put_bytes ) { return( ReadSynchronously( where_to_put_bytes ) ); }
  72.       inline  BOOL Read( const HANDLE event ) { return( ReadAsynchronously( event ) ); }
  73.  
  74.       /*
  75.       ** Operators
  76.       ** << & >>
  77.       */
  78. };
  79.  
  80. #endif // SERIAL_PORT_CLASS_HEADER
  81.